import request from '@/service'


export interface LawyerQueryParams {
  realname?: string;
  idCard?: string;
  licenseNo?: string;
  lawyerType?: string;
  workStatus?: string;
  userId?: number | string;
  page: number;
  pageSize: number;
}

// 证书接口类型
export interface Certificate {
  id?: number;
  lawyerId?: number;
  certificateName: string;
  certificateUrl?: string;
}

// 律师信息接口类型
export interface Lawyer {
  lawyerId: number | string;
  realname: string;
  sex: 'm' | 'f';
  nation: string;
  birthday?: string;
  graduateSchool: string;
  major: string;
  education: string;
  politicalStatus?: string;
  joinPartyDate?: string;
  idCard: string;
  phone: string;
  email?: string;
  residence?: string;
  licenseNo: string;
  qualificationDate?: string;
  businessSpecialty?: string;
  isPartner: 0 | 1;
  hireDate: string;
  lawyerType: string;
  partTimeWork?: string;
  representative: 0 | 1;
  award?: string;
  punishment?: string;
  workStatus: string;
  remark?: string;
  photo?: string;
  resume?: string;
  firstSocialSecurityDate?: string;
  socialSecurityNo?: string;
  socialDutie?: string;
  academicAchievements?: string;
  legalAdvisorUnits?: string;
  fileTransferRecordsUrl?: string;
  transferRecordsUrl?: string;
  certificates?: Certificate[];
}



// 获取角色列表
// 修正 API 定义
export const getLawyers = (params) => {
  return request.get('/lawyer/list', { params }) // 使用 params 传递查询参数
}

// 新增角色
export const addLawyer = (data) => {
  return request({
    url: '/lawyer/addLawyer',
    method: 'post',
    data,
  })
}

// 编辑角色
// @/api/lawyer.ts 中
export const editLawyer = (data: FormData) => {
  return request.put('/lawyer/editLawyer', data);  // 不要设置headers
}

// 删除角色
// 修复后的删除角色API
export const deleteLawyer = (ids:number[]) => {
  return request.delete('/lawyer/deleteLawyer', { data: ids })
}

export const getLawyerDetail = (lawyerId: number | string) =>
  request({ url: `/lawyer/${lawyerId}`, method: 'get' })

// 新增：通过userId查询律师信息
export const getLawyerByUserId = (userId: number | string) => {
  return request.get('/lawyer/byUserId', {
    params: { userId }
  })
}
